package com.zllkj.mm.adapter

import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.zllkj.mm.R
import com.zllkj.mm.common.ClientConfig
import com.zllkj.mm.module.shopping.vm.ItemAfterSaleListVM
import java.math.BigDecimal

class AfterSaleListAdapter(layoutResId: Int, data: List<ItemAfterSaleListVM?>?) :
        BaseQuickAdapter<ItemAfterSaleListVM, BaseViewHolder>(layoutResId, data) {
    override fun convert(baseViewHolder: BaseViewHolder, vm: ItemAfterSaleListVM) {
        baseViewHolder.getView<AppCompatTextView>(R.id.tv_after_sale_shop_name).text = vm.name
        baseViewHolder.getView<AppCompatTextView>(R.id.tv_after_sale_order_number).text = vm.afterSaleNo
        baseViewHolder.getView<AppCompatTextView>(R.id.tv_aftersale_each_one_goods_name).text = vm.goodsTitle
        Glide.with(mContext).load(ClientConfig.IMG_URL + vm.goodsPic).into(baseViewHolder.getView<AppCompatImageView>(R.id.iv_each_one_goods_image))
        baseViewHolder.getView<AppCompatTextView>(R.id.tv_aftersale_each_one_goods_unitPrice).text = "¥" + BigDecimal(vm.goodsUnitPrice).divide(BigDecimal("100")).toEngineeringString()
        baseViewHolder.addOnClickListener(R.id.tv_click_after_sales_order_detail)

    }
}